package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDownOrUpDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsQueryDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {


    @Autowired
    WmNewsService wmNewsService;

    @PostMapping("submit")
    public ResponseResult submit(@RequestBody WmNewsDto dto){
        return wmNewsService.submit(dto);
    }


    @PostMapping("list")
    public ResponseResult list(@RequestBody WmNewsQueryDto dto){
        return wmNewsService.listPage(dto);
    }


    @GetMapping("one/{id}")
    public ResponseResult getWmNews(@PathVariable("id") Integer id){
        return wmNewsService.getOneNews(id);
    }


    @GetMapping("del_news/{id}")
    public ResponseResult delNewsById(@PathVariable("id") Integer id){
        return wmNewsService.delNewsById(id);
    }


    @PostMapping("down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDownOrUpDto dto){
        return wmNewsService.downOrUp(dto);
    }




}
